﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sio.Mdm.Utils.Collections
{
    /// <summary>
    /// Event arguments for key/value pair operations
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TVal"></typeparam>
    public class KeyValuePairEventArgs<TKey, TVal> : EventArgs
    {
        /// <summary>
        /// COnstruct event arguments
        /// </summary>
        /// <param name="key"></param>
        /// <param name="val"></param>
        public KeyValuePairEventArgs(TKey key, TVal val)
        {
            _key = key;
            _val = val;
        }

        private TKey _key;
        /// <summary>
        /// Gets key for the operations
        /// </summary>
        public TKey Key
        {
            get
            {
                return _key;
            }
        }
        private TVal _val;
        /// <summary>
        /// Gets value for the operation
        /// </summary>
        public TVal Value
        {
            get
            {
                return _val;
            }
        }
    }

    /// <summary>
    /// Event arguments for canceling key/value pair operations
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TVal"></typeparam>
    public class KeyValuePairCancelEventArgs<TKey, TVal> : KeyValuePairEventArgs<TKey, TVal>
    {
        /// <summary>
        /// Construct event arguments
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public KeyValuePairCancelEventArgs(TKey key, TVal value)
            : base(key, value)
        {
        }

        private bool _cancel;
        /// <summary>
        /// Gets or sets wheater operation should be canceled
        /// </summary>
        public bool Cancel
        {
            get
            {
                return _cancel;
            }
            set
            {
                _cancel = value;
            }
        }
    }

    /// <summary>
    /// Event arguments used when key is replaced in dictionary
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class KeyReplacedEventArgs<T> : EventArgs
    {
        /// <summary>
        /// Construct event arguments
        /// </summary>
        /// <param name="oldKey"></param>
        /// <param name="newKey"></param>
        public KeyReplacedEventArgs(T oldKey, T newKey)
        {
            _old = oldKey;
            _new = newKey;
        }

        private T _old;
        /// <summary>
        /// Previous key value
        /// </summary>
        public T OldKey
        {
            get
            {
                return _old;
            }
        }
        private T _new;
        /// <summary>
        /// New key value
        /// </summary>
        public T NewKey
        {
            get
            {
                return _new;
            }
        }
    }
}
